<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>

        //创建一个对象,字面量的方式
        var job = {
            'place':'金证',
            'time':'9-18',
            'whaToDo':'test'
        }
        //这样写实际上是调用了new Object()
        console.log(job)

        //用构造器创建对象
        function Job(name){
            this.name = name
            this.place = '金证'
            this.time = '9-18'
            this.whaToDo = 'test'
        }
        var worker1 = new Job('caipeiyan')
        console.log(worker1)

        //用原型创建对象
        var worker2 = Object.create(job)
        worker2.name = 'cpp'
        worker2.whaToDo = 'do some develope'
        console.log(worker2)
        console.log(worker2.time)

        //用构造器创建对象和原型
        function NiceJob(name,salary){
            this.name =name
            this.salary= salary
        }
        NiceJob.prototype.place = 'everyWhere'
        NiceJob.prototype.time = 'noFixTime'
        NiceJob.prototype.whaToDo = function(){
            console.log(`我叫${this.name},我是一个打工人，每天的工作就是写代码，但是很自由，也不忙！`)
        }

        var worker3 =new NiceJob('caicai','3000usdt')
        // worker3 的原型是 NiceJob.prototype
        console.log(worker3)
        console.log(Object.entries(worker3))
        worker3.whaToDo()
    </script>
</head>
<body>
    
</body>
</html>